import type { App } from "vue";
import { useUserInfoStore } from "@/stores/userInfo";

   /*
      el 绑定事件的目标元素
      binding 对象，里面包含指令表达式
        binding.value 表达式的值

        例如：
          v-permission="'btn.User.add'"

          binding.value -> 'btn.User.add'
    */
const registerPermissionDirective=(app:App)=>{
  const useInfoStore=useUserInfoStore();
  app.directive("permission",(el,binding)=>{
if(!useInfoStore.buttons.includes(binding.value)){
  el.style.display="none"
}
  })
}
export default registerPermissionDirective;